#ifndef CANIMATION_H_
#define CANIMATION_H_


#include "stdafx.h"

enum AnimTypes {ONCE, LOOPING};

class CFrame;
class CEventSystem;
class CSGD_TextureManager;
class AnimInfo;

class CAnimation
{
private:
	vector<CFrame*> m_Frames;
	int m_nCurrFrame;
	bool m_bIsPlaying;
	float m_fTimeWaited;
	float m_fSpeed;
	int m_nImageID;
	string m_nAnimID;
	AnimTypes m_nAnimType;
	CEventSystem*	m_pEMs;
	CSGD_TextureManager* m_pTM;

public:
	CAnimation();
	~CAnimation();
	void Play();
	void Pause();
	void Resume();
	void Update(AnimInfo* anim, float fElapsedTime);
	void Reset();
	void Render(int& currframe, int nPosX, int nPosY, float fScale, float fRotation, bool bIsFlipped, DWORD dwColor);
	void AddFrame(CFrame* frame);
	void RemoveFrame();

	//Accessors
	vector<CFrame*>& GetFrames() {return m_Frames;}
	int GetCurrentFrame() {return m_nCurrFrame;}
	bool IsPlaying() {return m_bIsPlaying;}
	float GetTotalTime() {return m_fTimeWaited;}
	AnimTypes GetAnimationType() {return m_nAnimType;}
	int GetImageID() {return m_nImageID;}
	string GetAnimationID() {return m_nAnimID;}

	//Mutators
	void SetFrames(vector<CFrame*> frames) {m_Frames = frames;}
	void SetCurrentFrame(int frame) {m_nCurrFrame = frame;}
	void SetIsPlaying(bool playing) {m_bIsPlaying = playing;}
	void SetTotalTime(float time) {m_fTimeWaited = time;}
	void SetAnimationType(AnimTypes type) {m_nAnimType = type;}
	void SetImageID(int id) {m_nImageID = id;}
	void SetAnimationID(string id) {m_nAnimID = id;}
	void SetSpeed(float speed) {m_fSpeed = speed;}
};

#endif